<#-- 导入模版定义文件-->
<#include "../template/template_editPage.ftl">
<@edit title="游戏供货规则">
    <#if (id)??>
        <#assign isEdit = true />
    <#else>
        <#assign isAdd = true />
    </#if>



<body class="input">

<script type="text/javascript">
    $().ready(function () {

        var $validateErrorContainer = $("#validateErrorContainer");
        var $validateErrorLabelContainer = $("#validateErrorContainer ul");
        var $validateForm = $("#inputForm");
        var $tab = $("#tab");

        // Tab效果
        $tab.tabs(".tabContent", {
            tabs:"input"
        });

        // 表单验证
        $validateForm.validate({
            errorContainer:$validateErrorContainer,
            errorLabelContainer:$validateErrorLabelContainer,
            wrapper:"li",
            errorClass:"validateError",
            ignoreTitle:true,
            rules:{
                "gameSupplyRule.goodsId":{
                    required:true
                },
                "gameSupplyRule.goodsName":{
                    required:true
                },
                "goodsPriceDifference":{
                    required:true
                }

            },
            messages:{
                "gameSupplyRule.goodsId":{
                    required:"请选择一个商品！"
                },
                "gameSupplyRule.goodsName":{
                    required:"请选择一个商品名称！"
                },
                "goodsPriceDifference":{
                    required:"请填写商品差价！"
                }

            },


            submitHandler:function (form) {
                $(form).find(":submit").attr("disabled", true);
                form.submit();
            }
        });
        <#if actionErrors?? && (actionErrors?size > 0)>
            $.messager.show("提示信息", "<#list errorMessages as list>${list}<br></#list>", 2000);
        </#if>
    });
    function check1() {
        $("#priceSpan").html('');
        var e = /^(([1-9]\d{0,5})|0)(\.\d{1,3})?$/;
        var blsx = $("#price").val();
        if (!e.test(blsx)) {
            $("#priceSpan").html('价格格式不正确！(例：0.000)');
            return false;
        }
        else {
            return true;
        }
    }
</script>

<div class="body">
    <div class="inputBar">
        <h1><span class="icon">&nbsp;</span><#if isAdd??>添加游戏供货规则<#else>编辑游戏供货规则</#if></h1>
    </div>
    <div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
        <ul></ul>
    </div>
    <form id="inputForm" class="validate"
          action="<#if isAdd??>${web_base}/game/game_supply_rule!save.htm<#else>${web_base}/game/game_supply_rule!edit.htm</#if>"
          method="post">
        <ul class="tab">
            <li>
                <input type="button" value="基本信息" hidefocus="true"/>
            </li>
        </ul>
        <table class="inputTable tabContent">
            <tr style="display: none;">
                <th>
                    Id:
                </th>
                <td>
                ${(gameSupplyRule.id)!}
                    <input type="hidden" name="id" class="formText {required: true}"
                           value="${(gameSupplyRule.id)!}"/>
                </td>
            </tr>
                    <#if isAdd??>
                    <tr>
                        <th>
                            商品名称:
                        </th>
                    <td>
                        <select name="gameSupplyRule.goodsId" class="formText {required: true}">
                            <option value="">请选择商品名称</option>
                               <#if goodsNameList??>
                                    <#list goodsNameList as goods>
                                    <option value="${goods.goodsId!}">${goods.goodsName!}</option>
                                    </#list>
                               </#if>
                        </select>
                        <label class="requireField">*</label>
                    </td>
                    </tr>
                    <#else>
                    <tr>
                        <th>
                            商品编号:
                        </th>
                    <td>
                    ${(gameSupplyRule.goodsId)!}
                        <input type="hidden" name="gameSupplyRule.goodsId" class="formText {required: true}"
                               value="${(gameSupplyRule.goodsId)!}"/>
                    </td>
                    </tr>
                    <tr>
                        <th>
                            商品名称:
                        </th>
                        <td>
                        ${(gameSupplyRule.goodsName)!}
                            <input type="hidden" name="gameSupplyRule.goodsName" class="formText {required: true}"
                                   value="${(gameSupplyRule.goodsName)!}"/>
                        </td>
                    </tr>
                    </#if>

            <tr>
                <th>
                    商品差价(元):
                </th>
                <td>
                    <#if isAdd??>
                        <input id="price" name="goodsPriceDifference" type="text" class="formText {required: true}"
                               onblur="check1()"/>
                        <label class="requireField">*</label>
                        <span id="priceSpan" style="color: red;"></span>
                    <#else>
                        <input id="price" name="goodsPriceDifference" type="text" class="formText {required: true}"
                               onblur="check1()" value='${(gameSupplyRule.goodsPriceDifference*1.0/1000)?string("0.000")!}'/>
                        <label class="requireField">*</label>
                        <span id="priceSpan" style="color: red;"></span>
                    </#if>
                </td>
            </tr>
            <tr>
                <th>
                    备注:
                </th>
                <td>
                    <#if isAdd??>
                        <textarea class="formText" name="gameSupplyRule.remark" style="width:210px;height: 80px " value=""></textarea>
                    <#else>
                        <textarea type="text" class="formText" style="width:210px;height: 80px " name="gameSupplyRule.remark"
                                  value="">${(gameSupplyRule.remark)!}</textarea>
                    </#if>
                </td>
            </tr>

        </table>
        <div class="buttonArea">
            <input type="submit" class="formButton" <#if isAdd??> value="添  加" <#else>
                   value="更  新"</#if>hidefocus="true" onclick="return check1();" />&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回"
                   hidefocus="true"/>
        </div>
    </form>
</div>
</body>
</@edit>
